<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var phone = {
            name: '华为手机',
            price: 1000,
            makeCall: function () {
                console.log('打电话');
            },
            answerPhone: function () {
                console.log('接电话');
            }

        }
        console.log(phone.name);
        console.log(phone['name']);
        phone.makeCall();
        phone['answerPhone']();

        //构造函数的方式
        function Animal(name,age){
            this.name=name;
            this.age = age;
            this.show = function(){
                console.log(this.name, this.age,"动物");
            }
        }
        var animal = new Animal('猴子',5);
        console.log( animal.name,animal.age);
        animal.show();

        //Animal.prototype = phone;

        var animal2 = new Animal('大象',10);
        animal2.constructor        


    </script>
</body>

</html>